#include <bits/stdc++.h>

using namespace std;
#define int long long

void solve()
{
    int n, m;
    cin >> n >> m;
    int ma;
    if (!(m & 1))
    {
        cout << -1 << endl;
        return;
    }
    for (int i = 31; i >= 0; i--)
    {
        if (n & (1 << i))
        {
            ma = ((1 << (i + 1)) - 1);
            break;
        }
    }
    if (m > ma)
    {
        cout << -1 << endl;
        return;
    }
    int ans = 0;
    vector<bool> vis(n + 1, false);
    for (int i = 31; i > 0; i--)
    {
        if (m & (1 << i))
        {
            vis[1 << i] = true;
            cout << (1 << i) << ' ';
            ans++;
        }
    }
    for (int i = 1; i <= n; i++) if (!vis[i]) cout << i << ' ';
    cout << endl;
    cout << ans + 1 << endl;
    for (int i = 1; i <= ans; i++) cout << i << ' ' << i << endl;
    cout << ans + 1 << ' ' << n << endl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int _ = 1;
    //cin >> _;
    while (_--)
    {
        solve();
    }
    return 0;
}